﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataPageTools;
using System.Web.UI;

namespace CRM.Business
{
    public class ShowPageDispaly  : System.Web.UI.Page
    {
        /// <summary>
        /// 控制分页控件
        /// </summary>
        /// <param name="dp">绑定的分页控件</param>
        /// <param name="Num">页码</param>
        /// <param name="total">总记录数</param>
        public static void NewPageDispaly(DataPage dp, int Num, int total)
        {
            dp.TotalRecordCount = total;
            dp.ShowRecordCount = 15;

            int pageNum = Num;
            if (pageNum == 1)
            {
                dp.FirstPageDescription = "";
                dp.PageUpDescription = "";
                dp.LastPageDescription = dp.TotalRecordCount <= dp.ShowRecordCount ? "" : "尾页";
            }
            else if (dp.TotalRecordCount <= dp.ShowRecordCount && pageNum == 2)
            {
                dp.PageUpDescription = "";
                dp.FirstPageDescription = "";
                dp.LastPageDescription = "";
            }

            if (pageNum * dp.ShowRecordCount - dp.TotalRecordCount >= 0)
            {
                dp.LastPageDescription = "";
            }
        }
        public static void PageDispaly(DataPage list, int pageNum, int total)
        {
            #region 控制分页控件
            if (pageNum == 1)
            {
                list.FirstPageDescription = "1";
                if (total <= list.ShowRecordCount)
                {
                    list.LastPageDescription = "";
                }
                else
                {
                    list.LastPageDescription = "最后一页";
                }
            }
            else if (pageNum * list.ShowRecordCount - total >= 0)
            {
                list.LastPageDescription = "";
            }
            else
            {
                list.FirstPageDescription = "第一页";
                list.LastPageDescription = "最后一页";
            }
            #endregion
        }
    }
}
